package ch.bfh.abhmcm.SoftwareEngineeringAndDesign.view.mainframe.generateRFCPanel.generateRFCSubs.listeners;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import ch.bfh.abhmcm.SoftwareEngineeringAndDesign.controller.generateRFC.GenerateNewRFCThread;
import ch.bfh.abhmcm.SoftwareEngineeringAndDesign.view.mainframe.generateRFCPanel.GenerateRFCPanel;
import ch.bfh.abhmcm.SoftwareEngineeringAndDesign.view.mainframe.generateRFCPanel.generateRFCSubs.GenRFCFunctionPanel;

public class GenerateNewRFCButtonListener implements ActionListener
{
	private GenRFCFunctionPanel functionPanel;
	private GenerateRFCPanel generateRFCPanel;
	private GenerateNewRFCThread generateNewRFCThread;

	public GenerateNewRFCButtonListener(GenRFCFunctionPanel functionPanel, GenerateRFCPanel generateRFCPanel)
	{
		this.generateRFCPanel = generateRFCPanel;
		this.functionPanel = functionPanel;
	}

	public void actionPerformed(ActionEvent arg0)
	{
		this.generateNewRFCThread = new GenerateNewRFCThread(
				generateRFCPanel.getDatainputPanel(),
				functionPanel.getLb_progressbar());
		functionPanel.getBu_newRFC().setEnabled(false);
		functionPanel.getBu_editButton().setEnabled(false);
		functionPanel.getBu_cancel().setEnabled(true);
		functionPanel.getBu_sendRFC().setEnabled(true);
		functionPanel.getBu_save().setEnabled(true);
		functionPanel.getBu_deleteRFC().setEnabled(true);
		functionPanel.getLb_progressbar().setVisible(true);
		this.generateNewRFCThread.start();
	}
}